package com.youlai.boot.factory.model.form;

import java.io.Serial;
import java.io.Serializable;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.*;

/**
 * 租户数据源配置表单对象
 *
 * @author youlaitech
 * @since 2025-11-22 08:31
 */
@Getter
@Setter
@Schema(description = "租户数据源配置表单对象")
public class SysTenantDatasourceForm implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键ID")
    @NotNull(message = "主键ID不能为空")
    private Long id;

    @Schema(description = "租户ID（关联sys_tenant.id）")
    @NotNull(message = "租户ID（关联sys_tenant.id）不能为空")
    private Long tenantId;

    @Schema(description = "租户编码（冗余字段，方便查询）")
    @NotBlank(message = "租户编码（冗余字段，方便查询）不能为空")
    @Size(max=50, message="租户编码（冗余字段，方便查询）长度不能超过50个字符")
    private String tenantCode;

    @Schema(description = "数据源名称")
    @NotBlank(message = "数据源名称不能为空")
    @Size(max=100, message="数据源名称长度不能超过100个字符")
    private String datasourceName;

    @Schema(description = "数据源类型：MySQL、PostgreSQL等")
    @Size(max=20, message="数据源类型：MySQL、PostgreSQL等长度不能超过20个字符")
    private String datasourceType;

    @Schema(description = "驱动类名")
    @Size(max=100, message="驱动类名长度不能超过100个字符")
    private String driverClassName;

    @Schema(description = "数据库连接URL")
    @NotBlank(message = "数据库连接URL不能为空")
    @Size(max=500, message="数据库连接URL长度不能超过500个字符")
    private String url;

    @Schema(description = "数据库用户名")
    @NotBlank(message = "数据库用户名不能为空")
    @Size(max=100, message="数据库用户名长度不能超过100个字符")
    private String username;

    @Schema(description = "数据库密码（建议加密存储）")
    @NotBlank(message = "数据库密码（建议加密存储）不能为空")
    @Size(max=255, message="数据库密码（建议加密存储）长度不能超过255个字符")
    private String password;

    @Schema(description = "初始连接数")
    private Integer initialSize;

    @Schema(description = "最小空闲连接数")
    private Integer minIdle;

    @Schema(description = "最大活跃连接数")
    private Integer maxActive;

    @Schema(description = "最大等待时间(毫秒)")
    private Long maxWait;

    @Schema(description = "验证查询SQL")
    @Size(max=100, message="验证查询SQL长度不能超过100个字符")
    private String validationQuery;

    @Schema(description = "数据源状态：1-启用 0-禁用")
    private Integer status;

    @Schema(description = "是否主数据源：1-是 0-否（租户可能有多个数据源）")
    private Integer isPrimary;

    @Schema(description = "备注说明")
    @Size(max=500, message="备注说明长度不能超过500个字符")
    private String remark;

    @Schema(description = "创建时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @Schema(description = "创建人ID")
    private Long createBy;

    @Schema(description = "更新时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    @Schema(description = "更新人ID")
    private Long updateBy;

    @Schema(description = "逻辑删除(1-已删除 0-未删除)")
    @NotNull(message = "逻辑删除(1-已删除 0-未删除)不能为空")
    private Integer isDeleted;


}
